package ynu.edu.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ynu.edu.entity.User;
import ynu.edu.feign.ProviderFeignClient;

@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Autowired
    private ProviderFeignClient providerFeignClient;

    @GetMapping("/user/{id}")
    public User getUser(@PathVariable Long id) {
        return providerFeignClient.getUser(id);
    }

    @PostMapping("/user")
    public User createUser(@RequestBody User user) {
        return providerFeignClient.createUser(user);
    }

    @PutMapping("/user/{id}")
    public User updateUser(@PathVariable Long id, @RequestBody User user) {
        return providerFeignClient.updateUser(id, user);
    }

    @DeleteMapping("/user/{id}")
    public void deleteUser(@PathVariable Long id) {
        providerFeignClient.deleteUser(id);
    }
}